<extend name="default/template/mybase" />
<block name="area_header">
    <link rel="stylesheet" href="__PUBLIC__/Webview/css/detail.css?v=__APP_VERSION__"/>
</block>
<block name="area_body">
<div class="body">
	<img src="{:U('Api/Picture/index')}?id={$entry.main_img}" alt="" width="100%">
	<div class="th padded">{$entry.name}</div>
	<div class="price padded">{$entry.score}积分 <if condition="$entry.price neq 0">+ {$entry.price}元</if></div>
	<div class="bd">
		<div class="title padded">
    		<div class="line"></div>
    		<div class="title1">图文详情</div>
		</div>
        <article>
        <empty name="entry.detail">暂无描述<else />
            {$entry.detail|htmlspecialchars_decode}
        </empty>
	    </article>
	</div>
	<button class="am-btn exchange  btn-loading-example" data-url="{:U('ScoreGoods/exchange',array('uid'=>$uid,'psw'=>$psw,'pid'=>$entry['id'],'paycheck'=>$paycheck))}" >立即兑换</button>
</div>
<div class="am-modal am-modal-confirm" tabindex="-1" id="myconfirm">
  <div class="am-modal-dialog">
    <!-- <div class="am-modal-hd"></div> -->
    <div class="am-modal-bd">确定兑换{$entry.name}？</div>
    <div class="am-modal-footer">
      <span class="am-modal-btn" data-am-modal-cancel>取消</span>
      <span class="am-modal-btn" data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
<!-- alert -->
<div class="am-modal am-modal-alert" tabindex="-1" id="myalert">
  <div class="am-modal-dialog">
    <!-- <div class="am-modal-hd"></div> -->
    <div class="am-modal-bd">积分支付成功,即刻跳转</div>
    <div class="am-modal-footer">
      <span class="am-modal-btn " data-am-modal-confirm>确定</span>
    </div>
  </div>
</div>
<!-- alert end -->
</block>

<block name="area_footer">
	<script>
$(function(){
    var progress = $.AMUI.progress;
    $('.exchange').on('click', function() {
        progress.start();
        var url = $(this).data('url');
    	console.log(url);
        $('#myconfirm').modal({
            relatedTarget: this,
            onConfirm: function(options) {
                $.getJSON(url,function (data) {
                    // alert(data);
                    progress.done();
                    if(!data || !data.status){
                        myalert(data.info);
                    }else{
                        $('#myalert').modal({
                           relatedTarget: this,
                           onConfirm:function(options){
                            self.location = data.info;
                           }
                        })
                    }
                });
            },
            // closeOnConfirm: false,
            onCancel: function() {progress.done();}
        })
    });
    function myalert(con,ele){
        if(!ele) ele='myalert';
        if(!con) con='';
        $('#'+ele).find('.am-modal-bd').html(con)
        .end().modal();
    }
})
</script>
</block>